package com.xinshujia.wxxcx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xinshujia.wxxcx.pojos.entity.FunctionName;
import com.xinshujia.wxxcx.pojos.info.FunctionResultInFo;
import com.xinshujia.wxxcx.util.json.WriteOperation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @Author Cui Han
 * @Date 2024/5/17 17:54
 * @Description: TODO
 * @Version 1.0
 */
@Mapper
public interface FunctionsMapper extends BaseMapper<FunctionName> {
    /**
     * X轴阈值查询
     * @param functionNameX
     */
    @Insert("insert into `Function` (Time, DeviceGuid, `Function`,FunctionResult) values(#{time}, #{deviceGUID}, #{function},#{functionResult})")
    void insterXThreshold(FunctionName functionNameX);

    /**
     * Y轴阈值查询
     * @param functionNameY
     */
    @Insert("insert into `Function` (Time, DeviceGuid, `Function`,FunctionResult) values(#{time}, #{deviceGUID}, #{function},#{functionResult})")
    void insterYThreshold(FunctionName functionNameY);

    /**
     * Z轴阈值查询
     * @param functionNameZ
     */
    @Insert("insert into `Function` (Time, DeviceGuid, `Function`,FunctionResult) values(#{time}, #{deviceGUID}, #{function},#{functionResult})")
    void insterZThreshold(FunctionName functionNameZ);


    /**
     * 查询阈值
     * @param date
     * @return
     */
    @Select("select  FunctionResult from `Function` where Time = #{date}")
    List<FunctionResultInFo> findThreshold(Date date);

    /**
     * 关闭采集
     * @param functionName
     */
    @Insert("insert into `Function` (Time, DeviceGuid, `Function`,FunctionResult) values(#{time}, #{deviceGUID}, #{function},#{functionResult})")
    void insertCloseGather(FunctionName functionName);

    /**
     * 开启采集
     * @param startFunctionName
     */
    @Insert("insert into `Function` (Time, DeviceGuid, `Function`,FunctionResult) values(#{time}, #{deviceGUID}, #{function},#{functionResult})")
    void insertStart(FunctionName startFunctionName);

    /**
     * 清除报警记录
     * @param functionName
     */
    @Insert("insert into `Function` (Time, DeviceGuid, `Function`,FunctionResult) values(#{time}, #{deviceGUID}, #{function},#{functionResult})")
    void clearAlarm(FunctionName functionName);

    /**
     * 查询是否开启报警
     * @param functionName
     */
    @Insert("insert into `Function` (Time, DeviceGuid, `Function`,FunctionResult) values(#{time}, #{deviceGUID}, #{function},#{functionResult})")
    void insterAlarmSwitch(FunctionName functionName);

    /**
     * 修改阈值
     * @param functionName1
     */
    @Insert("insert into `Function` (Time, DeviceGuid, `Function`) values(#{time}, #{deviceGUID}, #{function})")
    void insertThreshold(FunctionName functionName1);

    /**
     * 清除报警
     * @param functionName2
     */
    @Insert("insert into `Function` (Time, DeviceGuid, `Function`,FunctionResult) values(#{time}, #{deviceGUID}, #{function},#{functionResult})")
    void clearAlarm1(FunctionName functionName2);


}

